﻿(function () {
    var educationsFactory = function ($http, $q) {
        var factory = {};
        factory.resumes = [];

        factory.getResumes = function () {
            var defered = $q.defer();
           
                $http({
                    method: 'GET',
                    url: '/api/ResumesLookup'
                }).success(function (data, status, headers, config) {
                    //$log.info(data, status, headers(), config);
                    defered.resolve(data);
                }).error(function (data, status, headers, config) {
                    //$log.warn(data, status, headers(), config);
                    defered.reject(status);
                });
            
            return defered.promise;
        };

        factory.getEducations = function () {
            var defered = $q.defer();

            $http({
                method: 'GET',
                url: '/api/Educations'
            }).success(function (data, status, headers, config) {
                //$log.info(data, status, headers(), config);
                defered.resolve(data);
            }).error(function (data, status, headers, config) {
                //$log.warn(data, status, headers(), config);
                defered.reject(status);
            });
            return defered.promise;
        };

        factory.updateEducation = function (education) {
            var defered = $q.defer();

            $http.put('/api/Education/' + education.id, education)
            .success(function (data, status, headers, config) {
                //$log.info(data, status, headers(), config);
                defered.resolve(data);
            }).error(function (data, status, headers, config) {
                //$log.warn(data, status, headers(), config);
                defered.reject(status);
            });
            return defered.promise;
        };

        return factory;
    };

    educationsFactory.$inject = ['$http', '$q'];
    angular.module('app').factory('educationsFactory', educationsFactory);
}());